# -*- encoding=utf-8 -*-
from selenium import webdriver
import requests
from selenium.webdriver.common.by import By

# 加上参数，禁止 chromedriver 日志写屏

option = webdriver.ChromeOptions()
option.add_argument("headless")
wd = webdriver.Chrome(
    r'c:\chromedriver.exe',
   # chrome_options=option,
    # options=option #指定上方配置的选项参数
)
# 设置最大等待时长为 10秒
wd.implicitly_wait(2)
# 用get方法打开网址
wd.get('http://192.168.1.110')
# 192.168.1.110
# wd.get('http://cdn1.python3.vip/files/selenium/sample1.html')

# 查找页面元素from selenium.webdriver.common.by import By
# element = wd.find_element_by_id('kw')
#

# wd.find_element(By.ID,'kw').send_keys('十翼')
# element = wd.find_element(By.CLASS_NAME,'bg')
# for e in element:
#     print(e.text)
# element.find_element(By.ID,'su').click()
# wd.find_element(By.ID,'su').click()

# element_list = wd.find_elements(By.CLASS_NAME,'plant')
# elements = wd.find_element(By.ID,'container')
# spans = elements.find_elements(By.TAG_NAME,'div')
# for e in spans:
#     print(e.text)
#
#
# print('ok')
import requests
from requests.auth import HTTPDigestAuth

if __name__ == '__main__':
    url = r'http://192.168.1.110'
    user = 'admin'
    password = '123456'
    response = requests.get(url, auth=HTTPDigestAuth(user, password))
    print(response.status_code)
    print(response.headers)